<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="trId" name="trId" value="${wechatUser.trId!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">邮箱</label>
              <div class="layui-input-block">
                  <input type="text" id="trEmail" name="trEmail" value="${wechatUser.trEmail!}"  autocomplete="off" placeholder="请输入邮箱"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">用户密码</label>
              <div class="layui-input-block">
                  <input type="text" id="trPasswrod" name="trPasswrod" value="${wechatUser.trPasswrod!}"  autocomplete="off" placeholder="请输入用户密码"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">用户电话</label>
              <div class="layui-input-block">
                  <input type="text" id="trPhone" name="trPhone" value="${wechatUser.trPhone!}"  autocomplete="off" placeholder="请输入用户电话"
                         class="layui-input">
              </div>
          </div>
          <#--<div class="layui-form-item">-->
              <#--<label class="layui-form-label">是否删除 0 正常/1删除</label>-->
              <#--<div class="layui-input-block">-->
                  <#--<input type="text" id="trIsDelete" name="trIsDelete" value="${wechatUser.trIsDelete!}"  autocomplete="off" placeholder="请输入是否删除 0 正常/1删除"-->
                         <#--class="layui-input">-->
              <#--</div>-->
          <#--</div>-->
          <#--<div class="layui-form-item">-->
              <#--<label class="layui-form-label">修改时间</label>-->
              <#--<div class="layui-input-block">-->
                  <#--<input type="text" id="trUpdateTime" name="trUpdateTime" value="${wechatUser.trUpdateTime!}"  autocomplete="off" placeholder="请输入修改时间"-->
                         <#--class="layui-input">-->
              <#--</div>-->
          <#--</div>-->
          <#--<div class="layui-form-item">-->
              <#--<label class="layui-form-label">创建时间</label>-->
              <#--<div class="layui-input-block">-->
                  <#--<input type="text" id="trCreateTime" name="trCreateTime" value="${wechatUser.trCreateTime!}"  autocomplete="off" placeholder="请输入创建时间"-->
                         <#--class="layui-input">-->
              <#--</div>-->
          <#--</div>-->
          <div class="layui-form-item">
              <label class="layui-form-label">关联小程序id </label>
              <div class="layui-input-block">
                  <input type="text" id="trOpenId" name="trOpenId" value="${wechatUser.trOpenId!}"  autocomplete="off" placeholder="请输入关联小程序id "
                         class="layui-input">
              </div>
          </div>
          <#--<div class="layui-form-item">-->
              <#--<label class="layui-form-label">是否为企业 0不是/1是企业</label>-->
              <#--<div class="layui-input-block">-->
                  <#--<input type="text" id="trIsCompany" name="trIsCompany" value="${wechatUser.trIsCompany!}"  autocomplete="off" placeholder="请输入是否为企业 0不是/1是企业"-->
                         <#--class="layui-input">-->
              <#--</div>-->
          <#--</div>-->


    <div class="layui-form-item">
        <label class="layui-form-label">用户定位</label>
        <div class="layui-input-block" id="userPositioning">
            <input type="radio" name="sex" value="0" title="用户" checked>
            <input type="radio" name="sex" value="1" title="企业" >
        </div>
    </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>



    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;

        $("input[name=sex][value=0]").attr("checked", ${wechatUser.trIsCompany!} == 0 ? true : false);
        $("input[name=sex][value=1]").attr("checked", ${wechatUser.trIsCompany!} == 1 ? true : false);
        form.render();




        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }
            // var userPositioning=$("#userPositioning input[name='sex']:checked ").val();

            var userPositioning= $('#userPositioning input[name="sex"]:checked ').val()

            console.log("userPositioning:"+userPositioning)
            var formDate = {
                         trId:$("#trId").val(),
                         trEmail:$("#trEmail").val(),
                         trPasswrod:$("#trPasswrod").val(),
                         trPhone:$("#trPhone").val(),
                         // trIsDelete:$("#trIsDelete").val(),
                         // trUpdateTime:$("#trUpdateTime").val(),
                         // trCreateTime:$("#trCreateTime").val(),
                         trOpenId:$("#trOpenId").val(),
                           trIsCompany: userPositioning
            }
            $.ajax({
                type: "POST",
                url: base+"/WeChatUser/wechatUser/admin/editWechatUser",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/WeChatUser/wechatUser/admin/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#trEmail").val().length<1){
                       layer.msg("请输入邮箱");
                       return false;
                   }
                   if($("#trPasswrod").val().length<1){
                       layer.msg("请输入用户密码");
                       return false;
                   }
                   if($("#trPhone").val().length<1){
                       layer.msg("请输入用户电话");
                       return false;
                   }
                   // if($("#trIsDelete").val().length<1){
                   //     layer.msg("请输入是否删除 0 正常/1删除");
                   //     return false;
                   // }
                   // if($("#trUpdateTime").val().length<1){
                   //     layer.msg("请输入修改时间");
                   //     return false;
                   // }
                   // if($("#trCreateTime").val().length<1){
                   //     layer.msg("请输入创建时间");
                   //     return false;
                   // }
                   if($("#trOpenId").val().length<1){
                       layer.msg("请输入关联小程序id ");
                       return false;
                   }
                   // if($("#trIsCompany").val().length<1){
                   //     layer.msg("请输入是否为企业 0不是/1是企业");
                   //     return false;
                   // }
        }
    });

</script>
</body>
</html>